package com.minimalist.common.entity.basic.po;


import com.minimalist.common.config.mybatis.InsertFullColumnHandler;
import com.minimalist.common.config.mybatis.UpdateFullColumnHandler;
import com.minimalist.common.config.mybatis.bo.BaseEntity;
import com.mybatisflex.annotation.Table;

import java.io.Serial;
import java.io.Serializable;
import java.util.Objects;

/**
 * 存储管理表 实体类。
 *
 * @author 小太阳
 * @since 2024-10-18
 */
@Table(value = "m_storage", onInsert = InsertFullColumnHandler.class, onUpdate = UpdateFullColumnHandler.class)
public class MStorage extends BaseEntity implements Serializable{

    @Serial
    private static final long serialVersionUID = 1L;

    private Long storageId;

    /**
     * 名称
     */
    private String storageName;

    /**
     * 存储类型，用于标识存储平台，如本地、阿里云oss、七牛云oss等
     */
    private String storageType;

    /**
     * 说明
     */
    private String description;

    /**
     * 存储配置，JSON数据
     */
    private String storageConfig;

    /**
     * 状态
     */
    private Integer status;

    // 无参构造函数
    public MStorage(){
    }

    // 全参构造函数
    public MStorage(Long storageId, String storageName, String storageType, String description, String storageConfig, Integer status){
        this.storageId = storageId;
        this.storageName = storageName;
        this.storageType = storageType;
        this.description = description;
        this.storageConfig = storageConfig;
        this.status = status;
    }

    // Getter和Setter方法
    public Long getStorageId(){
        return storageId;
    }

    public void setStorageId(Long storageId){
        this.storageId = storageId;
    }

    public String getStorageName(){
        return storageName;
    }

    public void setStorageName(String storageName){
        this.storageName = storageName;
    }

    public String getStorageType(){
        return storageType;
    }

    public void setStorageType(String storageType){
        this.storageType = storageType;
    }

    public String getDescription(){
        return description;
    }

    public void setDescription(String description){
        this.description = description;
    }

    public String getStorageConfig(){
        return storageConfig;
    }

    public void setStorageConfig(String storageConfig){
        this.storageConfig = storageConfig;
    }

    public Integer getStatus(){
        return status;
    }

    public void setStatus(Integer status){
        this.status = status;
    }

    // equals和hashCode方法
    @Override
    public boolean equals(Object o){
        if (this == o){
            return true;
        }
        if (o == null || getClass() != o.getClass()){
            return false;
        }
        if (!super.equals(o)){
            return false;
        }
        MStorage mStorage = (MStorage) o;
        return Objects.equals(storageId, mStorage.storageId) &&
                Objects.equals(storageName, mStorage.storageName) &&
                Objects.equals(storageType, mStorage.storageType) &&
                Objects.equals(description, mStorage.description) &&
                Objects.equals(storageConfig, mStorage.storageConfig) &&
                Objects.equals(status, mStorage.status);
    }

    @Override
    public int hashCode(){
        return Objects.hash(super.hashCode(), storageId, storageName, storageType, description, storageConfig, status);
    }

    // Builder模式
    public static MStorageBuilder builder(){
        return new MStorageBuilder();
    }

    public static class MStorageBuilder{
        private Long storageId;
        private String storageName;
        private String storageType;
        private String description;
        private String storageConfig;
        private Integer status;

        public MStorageBuilder storageId(Long storageId){
            this.storageId = storageId;
            return this;
        }

        public MStorageBuilder storageName(String storageName){
            this.storageName = storageName;
            return this;
        }

        public MStorageBuilder storageType(String storageType){
            this.storageType = storageType;
            return this;
        }

        public MStorageBuilder description(String description){
            this.description = description;
            return this;
        }

        public MStorageBuilder storageConfig(String storageConfig){
            this.storageConfig = storageConfig;
            return this;
        }

        public MStorageBuilder status(Integer status){
            this.status = status;
            return this;
        }

        public MStorage build(){
            return new MStorage(storageId, storageName, storageType, description, storageConfig, status);
        }
    }

    @Override
    public String toString(){
        return "MStorage{" +
                "storageId=" + storageId +
                ", storageName='" + storageName + '\'' +
                ", storageType='" + storageType + '\'' +
                ", description='" + description + '\'' +
                ", storageConfig='" + storageConfig + '\'' +
                ", status=" + status +
                '}';
    }
}
